function showSpecialPlateSearch() {
	window.location.href = "showSpecialPlateSearch.do";
}

function ajaxFindSpecialPlateSearchList(currentPage,pageSize) {
	$.ajax({
		type : "post",
		url : "ajaxSpecialPlateSearchList.do",
		data : {
			plateNum : $("#licencePlateKindNumber").val(),
			plateTypeId : $("#licencePlateKind").val(),
			matchWayId : $("#matchWayId").val(),
			currentPage:currentPage,
			pageSize:pageSize,
		},
		success : function(msg) {
			$("#listSpecialPlateBox").html(msg);
		}
	});
}

function ajaxShowSpecialPlateEdit(id){
	$.ajax({
		type:"post",
		url:"ajaxShowSpecialPlateEdit.do",
		data:{specialPlateId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 700,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons : [{
					text : "保存",
					click : function() {
						ajaxSaveSpecialPlate(this);
					}
				}, {
					text : "关闭",
					click : function() {
						$(this).dialog("close");
					}
				}]
			});
		}
	});
}

function ajaxSaveSpecialPlate(objDialog) {
	specialPlateValidate();
	if ($("#frmSpecialPlate").valid()) {
		$(objDialog).dialog("close");
		var options ={
				type: "post",
				url : "ajaxSaveSpecialPlate.do",
				success: function (msg) {
					clearInput("#sltSpecialPlate");
					ajaxFindSpecialPlateSearchList();
					showMessageDialog("保存特殊号牌","特殊号牌保存成功。",null,dialogType.info);
				}
		};
		$("#frmSpecialPlate").ajaxSubmit(options);
	}
}

function ajaxDeleteSpecialPlateById(id) {
	var specialPlateIds="";
	var sltSP = $("#listSpecialPlateList tbody input:checked").length;
	if(id==null){
		$("#listSpecialPlateList tbody input:checked").each(function() {
			specialPlateIds += $(this).val()+";";
		});
		if (specialPlateIds == "") {
			showMessageDialog("提示","请选择一行或多行",null,dialogType.info);
			return;
		}else{
			specialPlateIds=specialPlateIds.substring(0, specialPlateIds.length-1);
		}
	}else{
		specialPlateIds=id;
		sltSP = 1;
	}
	if( specialPlateIds!=null) {
		showMessageDialog("删除特殊号码","确定要删除所选“"+sltSP+"”条特殊号码记录吗？",
				function () {
			$.ajax({					
				type:"post",
				url:"ajaxDeleteSpecialPlateByIds.do",
				data:{specialPlateIds:specialPlateIds},
				success:function(msg){
					ajaxFindSpecialPlateSearchList();
					showMessageDialog("提示","特殊号码删除成功",null,dialogType.info);
				}
			});}
		,dialogType.warning);
	}
}

function specialPlateValidate(){
	$("#frmSpecialPlate").validate({
		errorLabelContainer: $("#infoSpecialPlate"),
		rules : {
			matchWayId : {
				required :true
			},
			plateTypeId : {
				required :true
			},
			plateNum : {
				required :true
			}
		},
		messages : {
			matchWayId : {
				required :"请输入匹配方式！"
			},
			plateTypeId : {
				required :"请输入号牌种类！"
			},
			plateNum : {
				required :"请输入号牌号码！"
			}
		},
		success: function(label) {
			label.html("&nbsp;");
		}
	});
}